package com.aaa.controller;

import com.aaa.service.impl.L_dataqueryServiceImpl;
import com.aaa.util.EmpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/dataSH")
public class L_dataSH {

    @Autowired
    L_dataqueryServiceImpl service;

    //文件上传下载路径
    @Value("${upload.path}")
    private String filePath; // D:/images/

    private String title;

@RequestMapping("/yemian")
    public String aaa(){
     service.panduan("SH");
    return  "redirect:../dataquery/dataquery";
}


@RequestMapping("/rightmain")
    public String rightmain(String title){
    this.title=title;
    return  "Declarationmanagement/rightmainSH";
}

//审核界面显示
@RequestMapping("/dataSH")
@ResponseBody
    public Map getall(@RequestBody Map map){
    map.put("title",title);
    Map map1=new HashMap();
    map1.put("data",service.getSH(map));
    map1.put("total",service.getSHcount(map));
    System.out.println(title);
    return  map1;
}

    @RequestMapping("/SHgo")
    @ResponseBody
    public Object SHgo(@RequestBody Map map){
    map.put("user", EmpUtil.getEmp().getUsername());
    Date date=new Date();
    SimpleDateFormat da=new SimpleDateFormat("yyyy-MM-dd");
    String time=da.format(date);
    map.put("time",time);

    System.out.println(map);

    List<Map> list=service.getkscore(map);
    System.out.println(list.get(0)+"          申报分数");
    System.out.println(list.size()+"       list");
    if (list.get(0)!=null){
        System.out.println("aaaaa  修改");
        service.setkscore(map);//分数相加
    }else if (list.get(0)==null){
        System.out.println("     新增");
        service.upkscore(map);//设置第一个分数
    }

    int i=service.SHgo(map);
    if (i>0){
        return true;
    }else {
        return  false;
    }
}


@RequestMapping("/SHreturn")
    @ResponseBody
    public Object SHreturn(@RequestBody Map map){
    service.SHreturn(map);
    System.out.println("aaaaaaaa");
    return  "";
}
}
